<?php 
require_once('class/cls_cliente.php');
//obtengo las divisiones de las secciones

$id_cliente=$_GET['pId'];

$objPaises=new clsCliente();
$Paises=$objPaises->ConsPaises();

$objTipoCliente =new clsCliente();
$TipoCliente=$objTipoCliente->ConsTipoCliente();

$objTipoID =new clsCliente();
$TipoID=$objTipoID->ConsTipoID();

//Consultar un Clinete
$objCliente =new clsCliente();
$Cliente=$objCliente->ConsClienteID($id_cliente);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>.::LIMEXPO ::.</title>
<link href="estilos/styles.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style4 {color: #ff0000}
body {
	background-image: url(images/1_03.png);
}
-->
</style>
<script>
function vacio(q)
{
    for ( i = 0; i < q.length; i++ )
	{
        if ( q.charAt(i) != " " ) 
		{ return true }
    }
    return false
}

function PasarNumero(cod)
{
	
	var datoseleccionado = cod; //document.getElementById("cmbPaises").value;
	var parentesis = "("
	var parentesis2 = ")"
	//alert(datoseleccionado);
    document.getElementById("txt_telefono").value=parentesis+datoseleccionado+parentesis2;
	document.getElementById("txt_celular").value=parentesis+datoseleccionado+parentesis2;
	document.getElementById("txt_trabajo").value=parentesis+datoseleccionado+parentesis2;
	
	
	
}

function Registrar()
{
		
                                     var F = document.forms['form_cliente'];		
                                     var formato = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;					
		var razon_social=document.getElementById("txt_razon_social").value;
		var ciudad=document.getElementById("txt_ciudad").value;
		var identificacion=document.getElementById("txt_identificacion").value;
		var email_per=document.getElementById("txt_email_per").value;
		var telefono=document.getElementById("txt_telefono").value;	
		var celular=document.getElementById("txt_celular").value;				
		var direccion=document.getElementById("txt_direccion").value;	
		var email_tra=document.getElementById("txt_email_trabajo").value;	
		var telefono_tra=document.getElementById("txt_trabajo").value;	
		var direccion_tra=document.getElementById("txt_direccion_tra").value;	
		var TCliente = document.getElementById('cmbTipoCliente').options[document.getElementById('cmbTipoCliente').selectedIndex].value;
		var ID = document.getElementById('cmbID').options[document.getElementById('cmbID').selectedIndex].value;
		var Pais = document.getElementById('cmbPaises').options[document.getElementById('cmbPaises').selectedIndex].value;
		 
		//Comprobamos los emails
		var v_email = formato.test(email_per);
 
		if((v_email != true)||(email_per == "")){
				alert('Email Personal esta vacio o el formato no es válido');
		return false;}
		
		var v_email2 = formato.test(email_tra);
 
		if(v_email2 != true){
			alert('Email del trabajo no válido');
			return false;}
						
		F.action="Inter_GuardarCliente.php";
		F.method="post";
		//F.submit();
		
  }
function validarNro(e) 
{
	var Pais = document.getElementById('cmbPaises').options[document.getElementById('cmbPaises').selectedIndex].value;
	//alert(Pais);
	if (Pais == "EC")
	{
	alert(Pais);
	var key;
	if(window.event) // IE
	{
		key = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		key = e.which;
	}
	if (key < 48 || key > 57)
	{
		if(key == 46 || key == 8 ) // Detectar . (punto) y backspace (retroceso)
		{ return true; } else { return false; }
		}
		return true;
	}

}
</script>
</head>

<body method="post">
<table width="744" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="21" colspan="4" align="right" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td width="22" height="46" align="right" valign="top" background="images/e_izquierda.png">&nbsp;</td>
    <td colspan="2" align="left" valign="bottom" bgcolor="#3a7da1" class="txtSubitulosBlanco style1"><img src="images/cliente.png" width="40" height="40" align="left" /><span class="TitleBlanco"> <br />
    Nuevo Cliente</span></td>
    <td width="46" align="left" valign="middle"><img src="images/e_derechapng.png" width="22" height="46" /></td>
  </tr>
  <tr>
    <td height="180" background="images/e_r_izquierda.png">&nbsp;</td>
    <td colspan="2" background="images/1_03.png">
    <form name="form_cliente" id="form_cliente" method="post" action="">
      <table width="615" border="0" align="center" cellpadding="0" cellspacing="0"  class="none">
        <!--DWLayoutTable-->
        <tr>
          <td height="6" align="right" valign="middle" class="textoazul10"></td>
        </tr>
        <tr>
          <td align="left" valign="middle"  class="noLinksCarr"><table width="698" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td class="textCalidadLink">Codigo:</td>
              <th scope="col"><label> </label>
                  <div align="left" >
                    <input name="txt_codigo" type="text" class="textazul" id="txt_codigo" tabindex="1" disabled="disabled" value="<?php echo($Cliente[0][0]);?>" />
                </div></th>
              <td colspan="2" rowspan="2"><table width="97" border="0" align="right" cellpadding="0" cellspacing="0">
                <tr>
                  <th width="53" scope="col">
                  <input  name="btn_nuevo" id="btn_nuevo" type="image" src="images/1361523217_stock_new-labels.png" alt="Nuevo Registro" title="Nuevo Registro" width="32" height="32" />                 </th>
                  <th width="63" scope="col">
                  <input  name="btn_guardar" onclick="Registrar();" id="btn_guardar" type="image" src="images/1361523271_Save.png" alt="Guardar" title="Guardar" width="32" height="32"  value="registrar"
                  />                  </th>
                </tr>
                <tr>
                  <th scope="col">&nbsp;</th>
                  <th scope="col">&nbsp;</th>
                </tr>
              </table></td>
              </tr>
            <tr>
              <th scope="col">&nbsp;</th>
              <th width="202" scope="col">&nbsp;</th>
            </tr>
            <tr>
              <td><span class="textCalidadLink">Tipo de Persona:</span></td>
              <td><label> </label>
                  <div align="left" >*
                    <?php 
				$totTC=count($TipoCliente);
			  ?>
                    <select  style="width:70" name="cmbTipoCliente" class="textazul" id="cmbTipoCliente" tabindex="1" >
                      <?php
						for($j=0;$j<$totTC;$j++)
						{
						
						?>
                      <option value="<?php echo($TipoCliente[$j][1]);?>" ><?php echo($TipoCliente[$j][0]);?></option>
                      <?php
						} //fin del for
						?>
                    </select>
                    <!--Fin Nuevo-->
                  </div></td>
              <td width="92"><span class="textCalidadLink">Pais:</span></td>
              <td width="263">*
                <?php 
				$totDiv=count($Paises);
			  ?>
                <select  name="cmbPaises" class="textazul" id="cmbPaises" tabindex="4" >
                 <?php
						for($j=0;$j<$totDiv;$j++)
						{
							$codigo = $Paises[$j][1];							
							$texto1=$Paises[$j][2];
							$texto2=$Paises[$j][3];
							$texto3=$texto1.$texto2;
						?>
                    <option onclick="JavaScript:PasarNumero('<?=$Paises[$j][4]?>')"  value="<?php echo($codigo);?>"><?php echo($texto3);?></option>
                     <?php
						} //fin del for
						?>
                </select></td>
            </tr>
            <tr>
              <td class="textCalidadLink">&nbsp;</td>
              <th scope="col">&nbsp;</th>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><span class="textCalidadLink">Razon Social:</span></td>
              <td>*
                <input name="txt_razon_social" type="text" class="textazul" id="txt_razon_social" tabindex="2" value="<?php echo($Cliente[0][1]);?>"/></td>
              <td><span class="textCalidadLink">Ciudad:</span></td>
              <td><label> </label>
                  <div align="left" >*
                    <input name="txt_ciudad" type="text" class="textazul" id="txt_ciudad"  tabindex="5" value="<?php echo($Cliente[0][6]);?>"/>
</div></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <th scope="col"><div align="left"></div></th>
              <th scope="col"><div align="left" ></div></th>
            </tr>
            <tr>
              <td><span class="textCalidadLink">Tipo de Identificacion:</span></td>
              <td>*
                <?php 
				$totID=count($TipoID);
			  ?>
                <select  style="width:70" name="cmbID" class="textazul" id="cmbID" tabindex="3">
                  <?php
						for($j=0;$j<$totID;$j++)
						{
						
						?>
                  <option value="<?php echo($TipoID[$j][1]);?>"><?php echo($TipoID[$j][0]);?></option>
                  <?php
						} //fin del for
						?>
                </select></td>
              <td><span class="textCalidadLink">Identificacion:</span></td>
              <td>*
                <input name="txt_identificacion" type="text" class="textazul" id="txt_identificacion" tabindex="6" onkeypress="javascript:return validarNro(event)" value="<?php echo($Cliente[0][4]);?>"/></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td colspan="4"><label></label></td>
              </tr>
            
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            
            
          </table></td>
        </tr>
        <tr>
          <td align="left" valign="middle" class="textazul"><div id="TabbedPanels1" class="TabbedPanels" background="images/1_03.png" >
            <ul class="TabbedPanelsTabGroup">
              <li class="TabbedPanelsTab" tabindex="0">Datos de Domicilio</li>
              <li class="TabbedPanelsTab" tabindex="0">Datos del Trabajo</li>
            </ul>
            <div class="TabbedPanelsContentGroup">
              <div class="TabbedPanelsContent">
                <table width="644" border="0" cellpadding="0" cellspacing="0" background="images/1_03.png">
                  <tr>
                    <td><span class="textCalidadLink">Email Pers.:</span></td>
                    <td background="images/1_03.png"><label> </label>
                        <div align="left" ><span class="style4">*</span>
                          <input name="txt_email_per" type="text" class="textazul" id="txt_email_per" tabindex="7" />
                      </div></td>
                    <td><span class="textCalidadLink">Direccion:</span></td>
                    <td rowspan="2"><label> </label>
                        <div align="left" ><span class="style4">*</span>
                          <textarea name="txt_direccion" class="textazul" id="txt_direccion" tabindex="10" value="<?php echo($Cliente[0][8]);?>"></textarea>
                      </div></td>
                  </tr>
                  <tr>
                    <td><span class="textCalidadLink">Telefono:</span></td>
                    <td background="images/1_03.png"><label> </label>
                        <div align="left" ><span class="style4">*</span>
                          <input name="txt_telefono" type="text" class="textazul" id="txt_telefono" tabindex="8" />
                      </div></td>
                    <td>&nbsp;</td>
                    </tr>
                  <tr>
                    <td><span class="textCalidadLink">Celular:</span></td>
                    <td><label> </label>
                        <div align="left" ><span class="style4">*</span>
                          <input name="txt_celular" type="text" class="textazul" id="txt_celular" tabindex="9"/>
                      </div></td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                </table>
              </div>
              <div class="TabbedPanelsContent">
                <table width="644" border="0" cellpadding="0" cellspacing="0" background="../images/1_03.png">
                  <tr>
                    <td><span class="textCalidadLink">Email :</span></td>
                    <td background="images/1_03.png"><label> </label>
                        <div align="left" > 
                          <input name="txt_email_trabajo" type="text" class="textazul" id="txt_email_trabajo" tabindex="11" />
                      </div></td>
                    <td><span class="textCalidadLink">Direccion:</span></td>
                    <td rowspan="2"><label> </label>
                        <div align="left" >
                          <textarea name="txt_direccion_tra" class="textazul" id="txt_direccion_tra" tabindex="13" value="<?php echo($Cliente[0][7]);?>"></textarea>
                      </div></td>
                  </tr>
                  <tr>
                    <td><span class="textCalidadLink">Telefono:</span></td>
                    <td background="images/1_03.png"><label> </label>
                        <div align="left" >
                          <input name="txt_trabajo" type="text" class="textazul" id="txt_trabajo" tabindex="12" />
                        </div></td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                </table>
              </div>
            </div>
          </div></td>
        </tr>
      </table>
    </form></td>
    <td align="right" valign="top" background="images/e_r_derecha1.png">&nbsp;</td>
  </tr>
  <tr>
    <td height="20" align="right" valign="top"><img src="images/e_infrerior_izquierda.png" width="22" height="19" /></td>
    <td height="20" colspan="2" align="left" valign="top" background="images/e_inferior.png" ></td>
    <td align="left" valign="top"><img src="images/e_inferior_derecha.png" width="22" height="19" /></td>
  </tr>
</table>
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
//-->
</script>
</body>
</html>
